<?php
#=====================================================================
#	Filename: app/www/models/search.php
#	Note	: 获取内容数据
#	Version : 3.0
#	Author  : qinggan
#	Update  : 2009-12-30
#=====================================================================
class search_m extends Model
{
	var $langid = "zh";
	var $psize = 20;
	function __construct()
	{
		parent::Model();
		$this->psize = defined("SYS_PSIZE") ? SYS_PSIZE : 20;
	}

	function search_m()
	{
		$this->__construct();
	}

	function langid($langid="zh")
	{
		$this->langid = $langid;
	}

	function get_list($offset=0,$keywords="")
	{
		$sql = "SELECT l.* FROM ".$this->db->prefix."list l JOIN ".$this->db->prefix."module m ON(l.module_id=m.id) WHERE l.status='1' AND l.hidden='0' AND m.insearch='1' ";
		$sql.= " AND l.langid='".$this->langid."' ";
		if($keywords)
		{
			$sql .= " AND l.title LIKE '%".$keywords."%' ";
		}
		$sql .= " ORDER BY l.post_date DESC,l.id DESC LIMIT ".$offset.",".$this->psize;
		//echo $sql;
		return $this->db->get_all($sql);
	}


	function get_count($keywords="")
	{
		$sql = "SELECT count(l.id) FROM ".$this->db->prefix."list l JOIN ".$this->db->prefix."module m ON(l.module_id=m.id) WHERE l.status='1' AND l.hidden='0' AND m.insearch='1' ";
		$sql.= " AND l.langid='".$this->langid."' ";
		if($keywords)
		{
			$sql .= " AND l.title LIKE '%".$keywords."%' ";
		}
		return $this->db->count($sql);
	}
}
?>